%*** input graph adjacency matrix G and nodal coordinates (for visualisation):
d_etoile = 0;

 %    [G,XY] = getgraph;   %   creation d'un graph test
 
 %[G,XY] = getgraphTree(18);   % creation de la matrice d'adjacence "arbre"
 %[G,XY] = getgraphBus(9);   % creation de la matrice d'adjacence "bus"
 [G,XY] = getgraphRing(9);   % creation de la matrice d'adjacence "anneau"
 %[G,XY] = getgraphDoublering(10);   % creation de la matrice d'adjacence "double anneau"
 %[G,XY] = getgraphStar(9);   % creation de la matrice d'adjacence "étoile"
 %[G,XY] = getgraphDoublestar(9);d_etoile=1;   % creation de la matrice d'adjacence "double étoile"
 %[G,XY] = getgraphTrianglemesh(9);   % creation de la matrice d'adjacence "triangle mesh"
 %[G,XY] = getgraphRhomboidmesh(9);   % creation de la matrice d'adjacence "triangle mesh"
%*** nnod: number of nodes, nseg: number of segments:
  nnod = size(G,1);
  nseg = nnz(G)/2;

%*** same volume of data (=1) is sent from all nodes to all nodes (equipotential):
  STraffic = 0*G;
  
  clients = [250000 150000 250000 150000 150000 150000 150000 150000 600000]  % For all

    if d_etoile == 0
      nfrom = 4;
      for nto = [3 2 5]
          [Paths,S] = gettraffic(G,nfrom,nto);
          S = S * clients(nto)*0.1*0.001; % traffic GB/s
          STraffic = STraffic + S;
      end;
      nfrom = 9;
      for nto = [8 7 1 6]
          [Paths,S] = gettraffic(G,nfrom,nto);
          S = S * clients(nto)*0.1*0.001;
          STraffic = STraffic + S;
      end;
  else
      nfrom = 8;
      for nto = [3 2 5]
          [Paths,S] = gettraffic(G,nfrom,nto);
          S = S * clients(nto)*0.1*0.001;
          STraffic = STraffic + S;
      end;
      nfrom = 9;
      for nto = [4 7 1 6]
          [Paths,S] = gettraffic(G,nfrom,nto);
          S = S * clients(nto)*0.1*0.001;
          STraffic = STraffic + S;
      end;
  end;
  


%--- STraffic(i,j) = t, the edge i <--> j transmitted (t) units of data, overall


%*** visualize graph and traffic:
  figure; clf
  gplot(G,XY);
  [i,j,k] = find(triu(STraffic));
  EXY = 0.3*XY(i,:) + 0.7*XY(j,:);
  tx1=text(EXY(:,1),EXY(:,2),num2str(k,'%3.1f'));
  [i,j,k] = find(triu(STraffic'));
  EXY = 0.3*XY(j,:) + 0.7*XY(i,:);
  tx2=text(EXY(:,1),EXY(:,2),num2str(k,'%3.1f'));
  hold on
  tx3 = text(XY(:,1),XY(:,2),num2str((1:nnod)'));
  set(tx1,'FontSize',18)
  set(tx2,'FontSize',18)
  set(tx3,'FontSize',18)
  set(tx3,'Color','r')
  axis equal
  axis off



%**** calculate length
[lengthNet] = getlength(G,XY,nnod);
hold on, 
ti=title(strcat('length:   ',num2str(lengthNet),';   internet traffic'));
set(ti,'FontSize',16);

